<template>
    <div>
    
        <cu-navbar>
            <block slot="content">客户</block>
        </cu-navbar>
        <view class="kehu-page page">
            <div class="tabs">
                <u-tabs active-color="#FF2E26" inactive-color='#888' :list="tabsList" :is-scroll="false"></u-tabs>
            </div>
        
            <div class="list">
                <div class="item f-r a-c j-b" v-for="item in list">
                    <div class="date">{{ item.realname }}</div>
                    <div class="value f-g">{{ item.mobile}}</div>
                </div>
            </div>
            <footer-page
                :page="page"
                :pagesize="pagesize"
                :page-size="pageSize"
                :page-total="pageTotal"
                @pre="pagePre"
                @next="pageNext"
            ></footer-page>
        </view>
    </div>

</template>

<script>
import footerPage from "@/components/footer-page/index.vue";
import page from '@/mixins/page'
export default {
    components: {
        footerPage,
    },
    mixins: [page],
		data() {
			return {
				tabsList: [
					{ name: '今日活跃(0)', value: '6' },
					{ name: '今日新增(0)', value: '0' },
					{ name: '全部(0)', value: '1' },
				],
				current: 0,
          list: []
			}
		},
      onPullDownRefresh() {
          this.page = 1
          this.getList()
      },
      onShow() {
          this.getList()
      },
      methods: {
          changeTab(index) {
              this.current = index;
              this.page = 1
              this.getList()
          },
          getList() {
              this.$api.kehu({page: this.page, pagesize: this.pagesize}).then(res => {
                  this.list = res.result.list
                  this.pageTotal = res.result.funsnum
                  this.pageSize = res.result.haspic || 0
                  this.funsnum = res.result.funsnum
                  this.funsntodaynumum = res.result.funsntodaynumum
                  this.haspic = res.result.haspic
                  const { haspic,todaynum,funsnum } = res.result
                  this.tabsList = [
                      { name: `今日活跃(${haspic})`, value: '6' },
                      { name: `今日新增(${todaynum})`, value: '0' },
                      { name: `全部(${funsnum})`, value: '1' },
                  ]
              }).finally(() => {
                  uni.stopPullDownRefresh()
              })
          },
      }
	}
</script>

<style lang="scss">
.kehu-page {
	.tabs {
		background-color: #fff;
	}
    .list {
        border-radius: 4px;
        padding: 20px 0;
        .item {
            background-color: #ffffff;
            font-size: 14px;
            color: #4a4a4a;
            border-bottom: 1px solid #eeeeee;
            padding: 10px 20px;
            .date{
                min-width: 60px;
                flex-shrink: 0;
                padding-left: 10px;
            }
            .value {
                margin: 0 20px;
            }
        }
    }

}
</style>
